#define  _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<assert.h>
#include<string.h>
char* my_strncat(char* dest, const char* str, size_t num)
{
	char* st = dest;
	int sz = strlen(str);
	assert(&dest&&str);
	while (*dest != '\0')
		dest++;
	while ((*dest++ = *str++)&&num>1)
		num--;
	if (num <= sz)
		*dest++ ='\0';
	return st;
}
int main()
{
	char arr1[20] = "abcd\0xxxxxxxxxxxxx";
	char arr2[] = "efghij";
	int num = 0;
	scanf("%d", &num);
	my_strncat(arr1, arr2, num);
	printf("%s\n", arr1);
	return 0;
}